package cn.dengta.webapp.trade.vo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

import cn.dengta.common.util.Formats;
import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.trade.entity.CashLog;
import cn.dengta.webapp.trade.model.*;
import cn.dengta.webapp.user.model.AuditStatus;
import cn.dengta.webapp.user.model.Gender;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.X;

@Getter
@Setter
public class CashLogVO extends AbstractVO<CashLog> {

	/** 用户名称 */
	private String userNickname;
	/** 提现币种 */
	private String currency;
	private Long accountId;
	/** 提现积分 */
	private BigDecimal integral;
	/** 提现金额 */
	private BigDecimal amount;
	/** 支付平台 */
	private transient Integer platform;
	/** 提现状态 */
	private transient Integer status;
	protected String orderNo;
	/** 第三方支付平台的提现订单号 */
	protected String thirdOrderNo;
	/** 备注 */
	private String remark;
	/** 用户 */
	private Map<String, Object> user;
	private Map<String, Object> agent;
	/** 可初审 */
	public boolean canVerify;
	/** 可复审 */
	public boolean canReview;
	/** 可线下转账 */
	public boolean canOffline;
	/** 可核查 */
	public boolean canCheck;
	/** 审核人 */
	protected Map<String, Object> verifyUser;
	/** 复审人 */
	protected Map<String, Object> reviewUser;
	protected Map<String, Object> checkUser;
	/** 性别 */
	public transient Gender gender;
	/** 昵称 */
	public transient String nickname;
	/** 银行卡号 */
	public String bankNumber;
	/** 真实姓名 */
	public String realName;
	/** 银行卡编码 */
	public String bankCode;
	/** 服务费 */
	public transient BigDecimal fee;
	/** 实到金额（=提现金额-服务费-坏账金额） */
	public transient BigDecimal realAmount;
	/** 返回消息 */
	public String responseMsg;
	/** 核查状态 */
	public Integer checkStatus;

	public String getGender_() {
		return X.map(gender, Gender::getLabel);
	}

	public static CashLogVO from(CashLog source) {
		return copy(source, CashLogVO::new);
	}

	public String getPlatform_() {
		return X.map(PayPlatform.of(platform), PayPlatform::name);
	}

	public String getStatus_() {
		return X.map(CashStatus.of(status), CashStatus::getLabel);
	}

	public String getCheckStatus_() {
		return CashStatus.OK.eq(status) ? X.map(AuditStatus.of(checkStatus), AuditStatus::getLabel) : "-";
	}

	public String getCurrency_() {
		return X.map(Currency.of(currency), Currency::getLabel);
	}

	@Override
	public Date getAddTime() {
		return super.getAddTime();
	}

	public String getFee_() {
		return Formats.formatNumber_M(fee);
	}

	public String getRealAmount_() {
		return Formats.formatNumber_M(realAmount);
	}

}
